package aad.storyboard.controller;

import java.util.HashMap;

import utils.ViewUtils;

import aad.storyboard.model.BlackFader;
import aad.storyboard.model.BlueFader;
import aad.storyboard.model.Fader;
import aad.storyboard.model.GreenFader;
import aad.storyboard.model.RedFader;
import aad.storyboard.model.YellowFader;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Bitmap.Config;


/**
 * Command pattern: maintains the mapping of fade strategies to colors
 */
public class FadeStrategyProvider {
	
	private static FadeStrategyProvider inst=new FadeStrategyProvider();
	private static HashMap<Integer, Fader> fadeStrategies=new HashMap<Integer, Fader>();
	private Bitmap fadeBitmap;
	
	private FadeStrategyProvider ()
	{
		fadeBitmap = Bitmap.createBitmap( ViewUtils.screenWidth,ViewUtils.screenHeight, Config.ARGB_8888); ; 
		
		 RedFader redfader=new RedFader(fadeBitmap); 
	     BlackFader blackfader=new BlackFader(fadeBitmap);
	     GreenFader gfader=new GreenFader(fadeBitmap);
	     YellowFader yfader=new YellowFader (fadeBitmap);     
	     BlueFader blfader=new BlueFader (fadeBitmap);
	     
	     fadeStrategies.put(Color.RED, redfader);
	     fadeStrategies.put(Color.BLACK, blackfader);
	     fadeStrategies.put(Color.BLUE, blfader);
	     fadeStrategies.put(Color.YELLOW, yfader);
	     fadeStrategies.put(Color.GREEN, gfader);
	}
	
	public static FadeStrategyProvider getInstance()
	{
		return inst;
	}
	
	public HashMap<Integer, Fader> getFadeStratiegies() {
		
		return fadeStrategies;
	}

	public Bitmap getFadeBitmap() {
		
		return fadeBitmap;
	}

	/**
	 * Strategy pattern: provides the client with  a correct Fader depending on the color specified
	 */
	public static Fader getFader(int i) {
		
		return fadeStrategies.get(i);
	}

	

}
